package horncomb.bpm.persistent;

import java.util.List;

import org.springframework.util.Assert;

import com.googlecode.horncomb.bean.filter.SimpleMapConditionSet;
import com.googlecode.horncomb.bean.order.DefaultOrder;
import com.googlecode.horncomb.orm.ibatis.SqlMapEntityDaoImpl;

import horncomb.bpm.task.core.TaskComment;

/**
 * DefaultTaskCommentEntity data access object
 * <p>
 * 负责人/principal:<br/>
 * 修改记录/revision:<br/>
 * 日期:<br/>
 * 修改人:<br/>
 * 修改说明:<br/>
 * @author
 * @version $Id$
 */
public class DefaultTaskCommentEntityDao extends
		SqlMapEntityDaoImpl<TaskComment> {
	private static final long serialVersionUID = -4670889050008988008L;

	/**
	 * @param taskInstanceId
	 * @return
	 */
	public List<? extends TaskComment> queryTaskComments(String taskInstanceId) {
		Assert.hasText(taskInstanceId);
		return this.query(new SimpleMapConditionSet().addConstraint(
				"taskInstanceId", taskInstanceId), new DefaultOrder()
				.addSortToken("CREATE_", false));
	}

	public List<? extends TaskComment> queryTaskCommentsInToken(String tokenId) {
		Assert.hasText(tokenId);
		return this.query(new SimpleMapConditionSet().addConstraint(
				"useTaskInstance", true).addConstraint("tokenId", tokenId),
				new DefaultOrder().addSortToken("CREATE_", false));
	}

	/**
	 * @param id
	 */
	public void deleteByTaskInstanceId(String taskInstId) {
		this.doDelete(new SimpleMapConditionSet().addConstraint(
				"taskInstanceId", taskInstId), this.deleteStatementName);
	}
}
